package cn.mes.module.mes.dal.mysql.baseworkplan;

import java.util.*;

import cn.mes.framework.common.pojo.PageResult;
import cn.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.mes.framework.mybatis.core.mapper.BaseMapperX;
import cn.mes.module.mes.dal.dataobject.baseworkplan.BaseWorkPlanDO;
import org.apache.ibatis.annotations.Mapper;
import cn.mes.module.mes.controller.admin.baseworkplan.vo.*;

/**
 * 任务单信息 Mapper
 *
 * @author 游创
 */
@Mapper
public interface BaseWorkPlanMapper extends BaseMapperX<BaseWorkPlanDO> {

    default PageResult<BaseWorkPlanDO> selectPage(BaseWorkPlanPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BaseWorkPlanDO>()
                .likeIfPresent(BaseWorkPlanDO::getWorkPlanId, reqVO.getWorkPlanId())
                .eqIfPresent(BaseWorkPlanDO::getWorkPlanInterId, reqVO.getWorkPlanInterId())
                .likeIfPresent(BaseWorkPlanDO::getProductName, reqVO.getProductName())
                .eqIfPresent(BaseWorkPlanDO::getCustomerId, reqVO.getCustomerId())
                .likeIfPresent(BaseWorkPlanDO::getCustomerName, reqVO.getCustomerName())
                .likeIfPresent(BaseWorkPlanDO::getUnitName, reqVO.getUnitName())
                .eqIfPresent(BaseWorkPlanDO::getUnitId, reqVO.getUnitId())
                .likeIfPresent(BaseWorkPlanDO::getCustomerProductId, reqVO.getCustomerProductId())
                .eqIfPresent(BaseWorkPlanDO::getMachineType, reqVO.getMachineType())
                .eqIfPresent(BaseWorkPlanDO::getMachineItem, reqVO.getMachineItem())
                .likeIfPresent(BaseWorkPlanDO::getProductShortName, reqVO.getProductShortName())
                .eqIfPresent(BaseWorkPlanDO::getProductGroupCode, reqVO.getProductGroupCode())
                .eqIfPresent(BaseWorkPlanDO::getWorkPlanType, reqVO.getWorkPlanType())
                .eqIfPresent(BaseWorkPlanDO::getWorkPlanTypeCode, reqVO.getWorkPlanTypeCode())
                .eqIfPresent(BaseWorkPlanDO::getWorkShopId, reqVO.getWorkShopId())
                .likeIfPresent(BaseWorkPlanDO::getWorkShopName, reqVO.getWorkShopName())
                .likeIfPresent(BaseWorkPlanDO::getProductGroup, reqVO.getProductGroup())
                .eqIfPresent(BaseWorkPlanDO::getWorkShopCode, reqVO.getWorkShopCode())
                .eqIfPresent(BaseWorkPlanDO::getWorkPlanProductNum, reqVO.getWorkPlanProductNum())
                .betweenIfPresent(BaseWorkPlanDO::getPlanStartTime, reqVO.getPlanStartTime())
                .betweenIfPresent(BaseWorkPlanDO::getPlanEndTime, reqVO.getPlanEndTime())
                .betweenIfPresent(BaseWorkPlanDO::getActualStartTime, reqVO.getActualStartTime())
                .betweenIfPresent(BaseWorkPlanDO::getActualEndTime, reqVO.getActualEndTime())
                .eqIfPresent(BaseWorkPlanDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BaseWorkPlanDO::getDistributeManagerId, reqVO.getDistributeManagerId())
                .eqIfPresent(BaseWorkPlanDO::getReceiveManagerId, reqVO.getReceiveManagerId())
                .eqIfPresent(BaseWorkPlanDO::getMoldNo, reqVO.getMoldNo())
                .eqIfPresent(BaseWorkPlanDO::getMoldCaveNum, reqVO.getMoldCaveNum())
                .eqIfPresent(BaseWorkPlanDO::getExchangeType, reqVO.getExchangeType())
                .eqIfPresent(BaseWorkPlanDO::getIsMoldSame, reqVO.getIsMoldSame())
                .eqIfPresent(BaseWorkPlanDO::getQuantity, reqVO.getQuantity())
                .betweenIfPresent(BaseWorkPlanDO::getGenerateDateTime, reqVO.getGenerateDateTime())
                .eqIfPresent(BaseWorkPlanDO::getGenerateUser, reqVO.getGenerateUser())
                .betweenIfPresent(BaseWorkPlanDO::getCloseDateTime, reqVO.getCloseDateTime())
                .betweenIfPresent(BaseWorkPlanDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(BaseWorkPlanDO::getWorkShopName)
                .orderByDesc(BaseWorkPlanDO::getWorkPlanId)
        );
    }

}